//
//  TitleCollectionCell.m
//  s.
//
//  Created by fanshijian on 2022/8/27.
//  Copyright © 2022 J. All rights reserved.
//

#import "TitleCollectionCell.h"

@interface TitleCollectionCell ()

@end

@implementation TitleCollectionCell

- (UILabel *)titleLab {
    if (!_titleLab) {
        UILabel *obj = [UILabel new];
        [self addSubview:_titleLab = obj];
        [obj mas_makeConstraints:^(MASConstraintMaker *make) {
            kMakeLV(15);
            kMakeRV(-15);
            kMakeCenterYV(0);
        }];
        obj.font = U_bfont(16);
        obj.textColor = JYColor_57();
        obj.numberOfLines = 0;
    }
    return _titleLab;
}

- (void)setModel:(TitleModel *)model {
    if (self.model != model || model.modified) {
        [super setModel:model];
        if (model.tf) {
            self.titleLab.font = model.tf;
        }else {
            self.titleLab.font = U_bfont(16);
        }
        if (model.title) {
            if ([model.title isKindOfClass:NSAttributedString.class]) {
                self.titleLab.attributedText = model.title;
            }else {
                self.titleLab.text = model.title;
            }
        }else {
            self.titleLab.text = @"";
        }
        self.titleLab.textAlignment = model.textAlignment;
        if (model.tColor) {
            self.titleLab.textColor = KLColor(model.tColor);
        }else {
            self.titleLab.textColor = JYColor_57();
        }
        if (model.titleMakerBlock) {
            [self.titleLab mas_remakeConstraints:model.titleMakerBlock];
        }
        
        if (model.color) {
            self.backgroundColor = KLColor(model.color);
        }else {
            self.backgroundColor = [UIColor clearColor];
        }
    }
}

@end
